Skip to content

Optimize numeric walk evaluation#159

Open
MichaelShalyt wants to merge 1 commit intomasterfrom
codex/optimize-numeric-walk-eval
Open

Optimize numeric walk evaluation#159
MichaelShalyt wants to merge 1 commit intomasterfrom
codex/optimize-numeric-walk-eval

Conversation

@MichaelShalyt
Copy link
Copy Markdown
Contributor

Summary

This change speeds up NumericMatrix.walk for the reduced one-symbol numeric walk path used by CMF.walk, without changing the public API or checkpoint behavior.

The optimization works by compiling the reduced rational matrix into:

  • one common denominator polynomial
  • integer coefficient tensors for the inflated entries

It then:

  • evaluates all step matrices in batch with a Vandermonde powers table
  • keeps the walk product in FLINT integer matrices
  • converts back to FLINT rationals only at the requested checkpoint depths

Multi-symbol direct numeric walks are unchanged and still use the previous evaluator.

Validated with:

direct unit tests for the optimized numeric walk path
sparse checkpoint tests
fallback coverage for multi-symbol walks
reduced 2F1 and 3F2 coverage
full ramanujantools suite

The Performance benefit is for reduced one-symbol walks at medium and larger depths.

Representative total-time comparison including setup costs:

pFq(2,1,-1), depth 1000: 0.0341s -> 0.0217s
pFq(3,2,1/4), depth 1000: 0.0754s -> 0.0390s
pFq(6,5,-1), depth 1000: 0.9992s -> 0.3796s
pFq(9,8,-1/2), depth 1000: 4.7452s -> 2.4830s

There is a first-call "compile" cost for the new path (which is still much smaller than the trajectory matrix calculation cost), but it is paid back quickly and the cumulative runtime becomes better as depth grows.

Cache is stored on the reduced matrix object.

Optimization is only enabled when the walk is:

  • one symbol
  • integer start point and step

Unsupported cases fall back to the previous implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant